import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:aweb5/util/WindowUtil.dart';
import 'package:aweb5/util/HttpUtils1.dart';
import 'package:aweb5/config/Config.dart';

class BaseWidget extends StatefulWidget {
  @override
  State<BaseWidget> createState() => BaseWidgetState();
}

class BaseWidgetState<T extends BaseWidget> extends State<T> {
  NavigatorState navigatorState;
  double windowWidth;
  String baseUrl=Config.baseUrl;
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    initWidth(context);
    initNaviState(context);
    return Scaffold();
  }

  void toast(String msg) {
    Fluttertoast.showToast(msg: msg);
  }

  void initNaviState(context) {
    navigatorState = Navigator.of(context);
  }

  PreferredSize appBarWithBack(String title) {
    return PreferredSize(
        child: AppBar(
          backgroundColor: Colors.white,
          elevation: 0,
          leading: GestureDetector(
            child: Container(
              padding: EdgeInsets.only(left: 6, right: 22, top: 10, bottom: 4),
              width: 40,
              height: 40,
              child: Image.asset(
                "assets/back.png",
                width: 12,
                height: 25,
              ),
            ),
            onTap: () {
              Navigator.of(context).pop();
            },
          ),
          title: Container(
            padding: EdgeInsets.only(top: 5),
            child: Text(
              title,
              style: TextStyle(
                  color: Colors.black,
                  fontWeight: FontWeight.bold,
                  fontSize: 18),
            ),
          ),
          centerTitle: true,
        ),
        preferredSize: Size.fromHeight(48));
  }
  PreferredSize appBar(String title) {
    return PreferredSize(
        child: AppBar(
          backgroundColor: Colors.white,
          elevation: 0,
          leading: Text(""),
          title: Container(

            padding: EdgeInsets.only(top: 5),
            child: Text(
              title,
              style: TextStyle(
                  color: Colors.black,
                  fontWeight: FontWeight.bold,
                  fontSize: 18),
            ),
          ),
          centerTitle: true,
        ),
        preferredSize: Size.fromHeight(48));
  }
  double initWidth(context) {
    windowWidth = MediaQuery.of(context).size.width;
    print(">>>");
  }

  double getHeight() {}
  init(context) {
    initWidth(context);
    initNaviState(context);
  }
}
